#pragma once
#include<iostream>
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#include <strings.h>
class Addr
{
public:
    Addr(struct sockaddr_in &addr)
    :_addr(addr)
    {
        _addr.sin_family=AF_INET;
        _port=ntohs(_addr.sin_port);
        _ip=inet_ntoa(_addr.sin_addr);
    }
    bool operator==(Addr& peer)
    {
        return _port==peer.Port()&&_ip==peer.Ip();
    }
    uint16_t Port()
    {
        return _port;
    }
    std::string Ip()
    {
        return _ip;
    }
    struct sockaddr_in& Sockaddr()
    {
        return _addr;
    }
    std::string GetAddr()
    {
        return _ip+"."+to_string(_port);
    }
    ~Addr()
    {}
private:
    uint16_t _port;
    std::string _ip;//点分十进制风格的ip
    struct sockaddr_in _addr;
};